﻿#include "OpeWidget.h"
#include <QDebug>

OpeWidget::OpeWidget(QWidget* parent) : QWidget(parent)
{
	m_pListWidget = new QListWidget(this);
	m_pListWidget->addItem("好友");
	m_pListWidget->addItem("图书");

	m_pFriend = new Friend;
	m_pBook = new Book;

	m_pStackWidget = new QStackedWidget;
	m_pStackWidget->addWidget(m_pFriend);
	m_pStackWidget->addWidget(m_pBook);

	QHBoxLayout* pMain = new QHBoxLayout;
	pMain->addWidget(m_pListWidget);
	pMain->addWidget(m_pStackWidget);

	setLayout(pMain);

	connect(m_pListWidget, SIGNAL(currentRowChanged(int)),
		m_pStackWidget, SLOT(setCurrentIndex(int)));

}

OpeWidget& OpeWidget::getInstance()
{
	qDebug() << "获取OpeWidget实例";
	static OpeWidget instance;
	return instance;
	// TODO: 在此处插入 return 语句
}

Book* OpeWidget::getBook()
{
	return m_pBook;
}

Friend* OpeWidget::getFriend()
{
	return m_pFriend;
}
